package at.ac.univie.zsu.aguataplan.ui;

import java.lang.reflect.InvocationTargetException;

import javax.swing.SwingUtilities;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Configurable;

import at.ac.univie.zsu.aguataplan.property.GeneralProperties;
import at.ac.univie.zsu.aguataplan.service.Services;

/**
 * starter class for SWING JFrame
 * 
 * @author gerry
 * 
 */
@Configurable
public class WindowStarter {
	private static Logger log = Logger.getLogger(WindowStarter.class);

	@Autowired
	private GeneralProperties generalProperties;
	@Autowired
	private Services services;

	// ----------------------------------------------------
	// CONSTRUCTOR
	// ----------------------------------------------------

	public WindowStarter() {

	}

	// ----------------------------------------------------
	// METHODS
	// ----------------------------------------------------

	@SuppressWarnings("unused")
	private void init() {
		try {
			SwingUtilities.invokeAndWait(new Runnable() {

				public void run() {
					new MainWindow(generalProperties, services);
				}
			});
		} catch (InterruptedException e) {
			log.fatal(e.toString());
		} catch (InvocationTargetException e) {
			log.fatal(e.toString());
		}
	}

	// ----------------------------------------------------
	// GETTER & SETTER
	// ----------------------------------------------------

	public GeneralProperties getGeneralProperties() {
		return generalProperties;
	}

	public void setGeneralProperties(GeneralProperties generalProperties) {
		this.generalProperties = generalProperties;
	}

	public Services getServices() {
		return services;
	}

	public void setServices(Services services) {
		this.services = services;
	}

}
